<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="template.xhtml">
	<ui:define name="content">
	
	<f:metadata>  
	    <f:viewParam name="packageId" value="#{personalizationBean.packageId}" /> 
	    <f:event listener="#{personalizationBean.loadData}" type="preRenderView"/>
	</f:metadata> 

	<br />
	<p:fieldset legend="Personalizza il tuo pacchetto viaggio!">
		<h2><h:outputText value="#{personalizationBean.pack.name}" /></h2>
		
		<h:form>
		<p:panelGrid columns="3">
			<f:facet name="header">  
	        	Ricerca pacchetto viaggio  
	    	</f:facet>
	    	
	    	<h:outputLabel value="Destinazione:" />
	    	<h:outputLabel value="#{personalizationBean.pack.location.name} (#{personalizationBean.pack.location.nation.name})" />
			<h:outputText />

			<h:outputLabel value="Hotel:" />  
	        <p:selectOneMenu converter="hotelConverter" var="av" value="#{personalizationBean.reservation.hotelAvailability}">   
	            <f:selectItems value="#{personalizationBean.hotelAvailabilities}" var="ha" itemValue="#{ha}" itemLabel="#{ha.hotelName} - #{ha.room.name}" />
	            <p:column>  
	                #{av.hotelName} - #{av.price} euro a notte<br />
	                #{av.room.name} per #{av.room.beds} persone<br/>Dal 
	                <h:outputText value="#{av.fromDate}" >
						<f:convertDateTime pattern="dd.MM.yyyy" />
					</h:outputText> al 
					<h:outputText value="#{av.toDate}" >
						<f:convertDateTime pattern="dd.MM.yyyy" />
					</h:outputText>
            	</p:column>   
	        </p:selectOneMenu>
	        <h:outputText value="Predefinito: #{personalizationBean.pack.hotel.name}" />
	        
	        <h:outputLabel value="Escursione:" />  
	        <p:selectOneMenu converter="excursionConverter" var="av" value="#{personalizationBean.reservation.excursionAvailability}">   
	            <f:selectItems value="#{personalizationBean.excursionAvailabilities}" var="ea" itemValue="#{ea}" itemLabel="#{ea.excursionName}" />
	            <p:column>  
	                #{av.excursionName} in data 
	                <h:outputText value="#{av.fromDate}" >
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
					</h:outputText><br />
					Prezzo: #{av.excursionPrice} a persona
            	</p:column>   
	        </p:selectOneMenu>
	        <h:outputText value="Predefinita: #{personalizationBean.pack.excursion.name}" />

			<h:outputLabel value="Volo di andata:" />  
	        <p:selectOneMenu converter="flightConverter" var="flight" value="#{personalizationBean.reservation.flight1}">   
	            <f:selectItems value="#{personalizationBean.flightsTo}" var="f" itemValue="#{f}" itemLabel="#{f.company}, partenza da #{f.airport1.name} (#{f.airport1.location.name})" />
	            <p:column>  
	                Compagnia aerea #{flight.company} - #{flight.price} euro a persona<br />
	                Partenza da #{flight.airport1.name} in data 
	                <h:outputText value="#{flight.departureTime}" >
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
					</h:outputText><br />
	                Arrivo a #{flight.airport2.name} in data 
	                <h:outputText value="#{flight.landingTime}" >
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
					</h:outputText> 
            	</p:column>    
	        </p:selectOneMenu>
	        <h:outputText />
	        
	        <h:outputLabel value="Volo di ritorno:" />  
	        <p:selectOneMenu converter="flightConverter" var="flight" value="#{personalizationBean.reservation.flight2}">   
	            <f:selectItems value="#{personalizationBean.flightsFrom}" var="f" itemValue="#{f}" itemLabel="#{f.company}, arrivo a #{f.airport2.name} (#{f.airport2.location.name})" />
	            <p:column>  
	                Compagnia aerea #{flight.company} - #{flight.price} euro a persona<br />
	                Partenza da #{flight.airport1.name} in data 
	                <h:outputText value="#{flight.departureTime}" >
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
					</h:outputText><br />
	                Arrivo a #{flight.airport2.name} in data 
	                <h:outputText value="#{flight.landingTime}" >
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
					</h:outputText> 
            	</p:column>  
	        </p:selectOneMenu>
	        <h:outputText />

	    	<h:outputLabel value="Persone partecipanti:" />
	    	<p:spinner suffix=" persone" value="#{personalizationBean.reservation.peopleNumber}" min="1"/>
	    	<h:outputText />
	    	
	    	<f:facet name="footer">
	    		<center>
	    			<p:button value="Indietro" outcome="packageDetails">
	    				<f:param name="packageId" value="#{personalizationBean.packageId}" />
	    			</p:button>
	    			<p:commandButton action="#{personalizationBean.validate}" value="Visualizza preventivo"></p:commandButton>
	    		</center>
	    	</f:facet>
		
		</p:panelGrid>
		</h:form>
		
		<br />
		<p:messages showDetail="true" autoUpdate="true" closable="true" />
		
	</p:fieldset>
	
	</ui:define>
</ui:composition>
</html>